'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { INTEGER, STRING, DATE } = Sequelize
    // 创建表
    await queryInterface.createTable('label', {
      id: {
        type: INTEGER(20).UNSIGNED,
        primaryKey: true,
        autoIncrement: true
      },
      wall_id: {
        type: INTEGER(20).UNSIGNED,
        allowNull: false,
        comment: '墙的id',
        references: {
          model: 'wall',
          key: 'id'
        },
        onUpdate: 'restrict',
        onDelete: 'cascade'
      },
      name: {
        type: STRING(30),
        allowNull: false,
        comment: '标签名称',
        unique: true
      },
      created_time: DATE
    })
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('label')
  }
}
